import {
  reqHeader,
  calcTime,
  proxy,
  getscene,
  getparamstr,
  limitLength,
  isAuthorization,
  formatDate
} from '../../utils/util.js';
import async from '../../libs/async.js';
import LoginStore from '../login/store.js';
import Swiper from './swiperInfo.js';
const app = getApp();

let startPoint;

let stopFlag = false;
let imgUrlsCoverInfo = [];
let getDefault = function() {
  return {
    navbarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '', //导航栏 中间的标题
      background: 'linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0))',
      hasFilter: true,
      color: '#FFFFFF',
      btnStyle: 'white', //black, white
    },
    navBarHeight: app.globalData.height,
    contentHeight: 0,
    imgUrls:[],
    currentIndex:0,
    shareBtnAnimaData: '',
    shareTextAnimaData: '',
    allText: true,
    photoData: {},
    page: 1,
    listData: [],
    popShow: false,
    mstyle: {
      marginTop: 0
    },
    windowHAW: {
      windowWidth: 0,
      windowHeight: 0
    },
    popStyle: {
      cls: 'hChange'
    },
    curUserAvatar: {},
    hasArrow: true,
    sharePop: false,
    canvasHeight: 0,
    videoStyle : {
      marginTop : 60,
      height : 225
    },
    canvasHidden: true,
    showLikeDetail:false,
    fullImgFlag:false,
    stopTouchMove: "",
    tipMsg: '',
    tipType: '',
    isChanging: true,
    indexChanged: true
  }
}
Page({
  data: getDefault(),
  setContentHeight() {
    let me = this;
    const query = wx.createSelectorQuery();
    query.select('.detail_content').boundingClientRect()
    query.selectViewport().scrollOffset()
    query.exec(function (res) {
      me.setData({
        contentHeight: res[0].height,
        isChanging: false
      })
    })
  },
  sharePopShow:function(){
    if (this.data.photoData.openState === 'public' || this.data.photoData.openState === 'private') {
      this.setData({
        tipMsg: '私有作品不能操作哦~',
        tipType: 'normal'
      })
    } else {
      this.setData({
        sharePop: true
      });
    }
  },
  closeSharePop:function(e){
    this.setData({
      sharePop: false
    });
    if (e.detail.makePoster) {
      this.makePoster();
    }
  },
  makePoster:function(){
    wx.showLoading({
      title: '生成中...',
      mask: true
    });

    let me = this;
    let photoData = this.data.photoData;

    let opt = this.data.options;
    let paramStr = `${photoData.id}&${photoData.resourceType}&share`;
    if (opt.fromType){
      paramStr += `&${opt.fromType}`;
    }
    if (opt.fromResourceId){
      paramStr += `&${opt.fromResourceId}`;
    }
    getscene(paramStr, (scene)=>{
      let photo_obj = [{
        url: photoData.url.p3
      }]
      if (photoData.resourceType == 2){
        photo_obj=[];
        for (let itemValue of photoData.photos){
          photo_obj.push({
            url: itemValue.url.p3
          })
        }
      }
      let logo_obj = {
        url: 'https://node.500px.me/images/WeChat/logo500.png'
      }
      let avatar_obj = {
        url: photoData.uploaderInfo.avatar.a1
      }
      let erweima_obj = {
        url: `https://node.500px.me/weChat/queryCodeImg?page=pages/detail/detail&scene=${scene}`
      }
      async.forEach([...photo_obj, logo_obj, avatar_obj, erweima_obj], (item,callback) =>{
        wx.getImageInfo({
          src: item.url,
          success: function (res) {
            item.res = res;
            callback();
          },
          fail: function (e) {
            console.log(e)
          }
        });

      },function(){
        let canvasWidth = me.data.screenWidth;
        let photoHeight = 0;
        if (photo_obj instanceof Array){
          for (let objItem of photo_obj){
            let curPhotoHeight = objItem.res.height / objItem.res.width * canvasWidth;
            photoHeight += curPhotoHeight
          }
        }
        let canvasHeight = photoHeight + 123;

        me.setData({
          canvasHidden: false,
          canvasHeight: canvasHeight
        },()=> {
          var context = wx.createCanvasContext('myCanvas');

          context.fillStyle = "#fff";
          context.fillRect(0, 0, canvasWidth + 10, canvasHeight + 10);

          if (photo_obj instanceof Array) {
            let tplHeight = 0
            for (let objItem of photo_obj) {
              let curPhotoHeight = objItem.res.height / objItem.res.width * canvasWidth;
              context.drawImage(objItem.res.path, 0, tplHeight, canvasWidth + 2, curPhotoHeight);
              tplHeight += curPhotoHeight
            }
          }

          context.drawImage(logo_obj.res.path, 16, photoHeight - 30, 203/2, 31/2);

          context.save();
          let r = 10;
          let d = r * 2;
          let cx = 20;
          let cy = photoHeight + 65;
          context.beginPath();
          context.arc(cx + r, cy + r, r, 0, 2 * Math.PI);
          context.setStrokeStyle('#FFFFFF');
          context.stroke();
          context.clip();
          context.drawImage(avatar_obj.res.path, cx, cy, d, d);
          context.restore();

          context.setFontSize(17);
          context.setTextAlign('left');
          context.setTextBaseline('top');
          context.setFillStyle("#525558");
          let titleText = limitLength(photoData.title);
          context.fillText(titleText, 20, photoHeight + 37);

          context.setFontSize(12);
          context.setTextAlign('left');
          context.setTextBaseline('top');
          context.setFillStyle("#B9C1C7");
          let nickNameText = limitLength(photoData.uploaderInfo.nickName);
          context.fillText(nickNameText, 45, photoHeight + 69);

          context.drawImage(erweima_obj.res.path, canvasWidth - 92, photoHeight + 16, 72, 72);

          context.setFontSize(10);
          context.setTextAlign('right');
          context.setTextBaseline('top');
          context.setFillStyle("#525558");
          context.fillText('扫描或长按小程序码', canvasWidth - 11, photoHeight + 93);

          context.draw(false,()=>{
            setTimeout(function () {
              wx.canvasToTempFilePath({
                canvasId: 'myCanvas',
                fileType: 'jpg',
                success: function (res) {
                  wx.hideLoading();
                  me.setData({
                    canvasHidden: true
                  });
                  wx.previewImage({
                    current: res.tempFilePath,
                    urls: [res.tempFilePath]
                  })
                }
              })
            }, 500);
          });
        });
      })
    })

  },
  FullImg:function(){
    this.setData({
      fullImgFlag: !this.data.fullImgFlag,
      stopTouchMove: !this.data.fullImgFlag ? 'stopTouchMove' : ''
    })
  },
  groupFullImg:function(){
    let resourceType = this.data.photoData.resourceType;
    let photoList = '';
    for (let item of this.data.photoData.photos) {
      photoList += `${item.url.baseUrl}!p4,`
    }
    wx.navigateTo({
      url: `/pages/groupFull/groupFull?photoList=${photoList}&resourceType=${resourceType}`,
    })
  },
  closeLikePop:function(){
    setTimeout(() => {
      this.setData({
        showLikeDetail: false
      })
    }, 202);
  },
  closePop: function(e) {
    let photoData = this.data.photoData;
    photoData.commentCount = e.detail.curCommentCount;
    setTimeout(() => {
      this.setData({
        popShow: false,
        photoData: photoData
      })
    }, 202);

  },
  viewAllText: function() {
    this.setData({
      allText: !this.data.allText
    });
  },
  changePhotoList: function() {
    let me = this;
    let userAccountInfo = LoginStore.userInfo || {};
    wx.request({
      url: `${proxy}/community/discover/recommendTime`,
      data: {
        resourceType: '0,2',
        startTime: '',
        page: this.data.page,
        size: 4,
        type: 'json',
        access_token: userAccountInfo.access_token || ''
      },
      header: reqHeader,
      success: function(res) {
        if (res.statusCode == 200) {
          if(res.data instanceof Array){
            me.setData({
              listData: res.data,
              page: me.data.page + 1
            });
          }
        } else {
          console.log(res.message);
        }
      }
    });
  },
  commentsHandler: function(e) {
    if (!isAuthorization(e)) {
      return;
    }
    LoginStore.validateLogin(()=>{
      let userAccountInfo = LoginStore.userInfo;
      let avatar = "https://img.500px.me/default_tx.png!a1";
      if (userAccountInfo.avatar.a1) {
        avatar = userAccountInfo.avatar.a1;
      }
      this.setData({
        popShow: true,
        popParams: {
          userAvatar: avatar,
          id: this.data.photoData.id,
          uploaderId: this.data.photoData.uploaderId
        }
      });
    })

  },
  likeHandler: function(e) {
    if (!isAuthorization(e)) {
      return;
    }
    let me = this;
    LoginStore.validateLogin(()=>{
      let userAccountInfo = LoginStore.userInfo;
      let photoData = this.data.photoData;
      if (userAccountInfo.userId == photoData.uploaderId) {
        me.setData({
          showLikeDetail:true,
          popParams:{
            count: photoData.pictureLikeedCount,
            popKey: "liked",
            curUserId: photoData.id
          }
        })
        return;
      }

      if (photoData.userLikerState == undefined) {
        me.afterLoginFun(me.data.options);
        return;
      }
      let actionFlag = 1;
      if (photoData.userLikerState) {
        actionFlag = 0;
      }
      wx.request({
        url: `${proxy}/community/doLike.do`,
        data: {
          action: actionFlag,
          likedId: photoData.id,
          byAction: userAccountInfo.userId,
          access_token: userAccountInfo.access_token
        },
        header: reqHeader,
        success: function (res) {
          res = res.data;
          if (res.status == 200) {
            if (photoData.userLikerState) {
              photoData.pictureLikeedCount--;
            } else {
              photoData.pictureLikeedCount++;
            }
            photoData.userLikerState = !photoData.userLikerState;
            me.setData({
              photoData: photoData
            });
          } else {
            console.log(res.message);
          }
        }
      });
    })

  },
  clickPhoto: function(e) {
    let item = e.currentTarget.dataset.item;
    Swiper.setData({
      imgUrls: this.data.listData,
      urlStr: `${proxy}/community/discover/recommendTime`,
      params: {
        resourceType: '0,2',
        startTime: '',
        page: this.data.page,
        size: 4,
        type: 'json'
      },
      selectedID: item.id
    });

    let urlStr = `/pages/detail/detail?id=${item.id}&resourceType=${item.resourceType}&fromType=&fromResourceId=`;
    let pageList = getCurrentPages();
    if (pageList.length >= 8) {
      wx.redirectTo({
        url: urlStr,
      })
    } else {
      wx.navigateTo({
        url: urlStr
      });
    }
  },

  toUserInfo: function(e) {
    let callback = ()=>{
      let urlStr = '/pages/userInfo/userInfo?userId=' + userId;
      let pageList = getCurrentPages();
      if (pageList.length >= 8) {
        wx.redirectTo({
          url: urlStr,
        })
      } else {
        wx.navigateTo({
          url: urlStr
        });
      }
    }
    let userId = '';
    if (e.currentTarget.dataset.userid) {
      userId = e.currentTarget.dataset.userid;
      callback();

    }else{
      if (!isAuthorization(e)){
        return;
      }

      LoginStore.validateLogin(() => {
        userId = LoginStore.userInfo.userId;
        callback();
      })

    }
  },
  shareAnimation:function(){
    this.setData({
      showlandi: true
    }, () => {
      var animation = wx.createAnimation({
        duration: 400,
        timingFunction: 'linear',
        delay: 200
      });
      var animation2 = wx.createAnimation({
        duration: 400,
        timingFunction: 'linear',
        delay: 200
      });
      animation2.left(72).step();
      animation.width(117).step();
      this.setData({
        sharebgTextAnimaData: animation.export(),
        shareBtnAnimaData: animation2.export()
      }, () => {
        setTimeout(() => {
          var animation3 = wx.createAnimation({
            duration: 100,
            timingFunction: 'ease',
          });
          animation3.opacity(1).step();
          this.setData({
            shareTextAnimaData: animation3.export()
          })
        }, 600)
      })
    })
  },
  resolveMsg: function (desc) {
    let msgTextList = [];
    let tplMsgStr = '';
    let res = desc.match(/<a\b[^>]+\bhref="[^"]*"[^>]*\b(?:topic_id|user_id)="[^"]+">[\s\S]*?<\/a>/gi);
    if (res != null) {
      let resList = desc.split(/(<a\b[^>]+\bhref="[^"]*"[^>]*\b(?:topic_id|user_id)="[^"]+">[\s\S]*?<\/a>)/);
      resList.forEach((value, i) => {
        if (value) {
          let hasUser = value.match(/<a\b[^>]+\bhref="[^"]*"[^>]*\buser_id="[^"]+">[\s\S]*?<\/a>/gi);
          let hasTopic = value.match(/<a\b[^>]+\bhref="[^"]*"[^>]*\btopic_id="[^"]+">[\s\S]*?<\/a>/gi);
          if (hasUser != null) {
            let splitRes = value.split(/<a\b[^>]+\bhref="[^"]*"[^>]*\buser_id="([^"]+)">([\s\S]*?)<\/a>/);
            let descStr = splitRes[2];
            if (!msgTextList.length) {
              descStr = descStr.replace(/(^\s*)/g, "");
            };
            msgTextList.push({
              type: 'user',
              desc: descStr,
              id: splitRes[1]
            })
          } else if (hasTopic != null) {
            let splitRes = value.split(/<a\b[^>]+\bhref="[^"]*"[^>]*\btopic_id="([^"]+)">([\s\S]*?)<\/a>/);
            let descStr = splitRes[2];
            if (!msgTextList.length) {
              descStr = descStr.replace(/(^\s*)/g, "");
            };
            msgTextList.push({
              type: 'topic',
              desc: descStr,
              id: splitRes[1]
            })
          } else {
            msgTextList.push({
              type: 'text',
              desc: value
            });
            tplMsgStr += value;
          }
        }
      })

    } else {
      msgTextList.push({
        type: 'text',
        desc: desc
      });
      tplMsgStr += desc;
    }

    return {
      msgTextList,
      tplMsgStr
    }
  },
  turnToLinkDetail(e) {
    let desc = e.currentTarget.dataset.desc;
    if (desc.type === 'topic') {
      wx.navigateTo({
        url: `/pages/topic/topic?topicId=${desc.id}`,
      })
    } else if (desc.type === 'user') {
      wx.navigateTo({
        url: `/pages/userInfo/userInfo?userId=${desc.id}`,
      })
    }
    return
  },
  afterLoginFun: function(options) {
    let userAccountInfo = LoginStore.userInfo;
    let me = this;
    let urlStr = `${proxy}/community/photo-details/${options.id}`;
    if (options.resourceType && options.resourceType == 2){
      urlStr = `${proxy}/community/v2/groupPhoto/detail/${options.id}`;
    }
    let dataParams = {
      imgsize: 'p1,p2,p3,p5,p6',
      type: 'json',
      access_token: userAccountInfo.access_token || ''
    };
    if (options.fromType){
      dataParams.fromType = options.fromType ;
    }
    if (options.fromResourceId){
      dataParams.fromResourceId = options.fromResourceId;
    }

    wx.request({
      url: urlStr,
      data: dataParams,
      header: reqHeader,
      success: function(res) {
        if (res.statusCode == 200) {
          if (typeof (res.data) == "string"){
            wx.hideLoading();
            wx.showModal({
              title: '提示',
              content: '作者已删除该作品',
              showCancel:false,
              success: function (res) {
                if (res.confirm) {
                  let pages = getCurrentPages();
                  if (pages.length == 1){
                    wx.navigateTo({
                      url: `/pages/contestList/contestList`,
                    });
                  }else{
                    let prevPage = pages[pages.length - 2];
                    prevPage.setData({
                      freshMark: true
                    }, function () {
                      wx.navigateBack({
                        delta: 1
                      })
                    });
                  }

                }
              }
            })
            return;
          }

          // if (res.data.resourceType && res.data.resourceType == 4) {
          //   wx.redirectTo({
          //     url: '/pages/contestList/contestList',
          //   });
          //   return;
          // }

          if (options.resourceType && options.resourceType == 2) {
            res = res.data;
          }
          res.data.resolvedDescription = {};
          if (res.data.description) {
            res.data.resolvedDescription = me.resolveMsg(res.data.description)
          }
          let uploadTime = new Date(res.data.uploadedDate);
          res.data.afterChangeTime = calcTime(uploadTime);
          if (!res.data.uploaderInfo.avatar.baseUrl) {
            res.data.uploaderInfo.avatar.a1 = 'https://img.500px.me/default_tx.png!a1';
          }

          res.data.ratingMax = res.data.ratingMax.toFixed(1);
          res.data.uploadedDateNew = formatDate(new Date(res.data.uploadedDate));
          if (res.data.exifInfo && res.data.exifInfo.dateTimeOriginal){
            res.data.exifInfo.dateTimeOriginalNew = formatDate(new Date(res.data.exifInfo.dateTimeOriginal));
          }

          let setObj = {
            photoData: res.data,
            curUserAvatar: LoginStore.userInfo.avatar || {},
            options: options,
            appParams:JSON.stringify({
              category:"photoDetail",
              id: res.data.id,
              resourceType: res.data.resourceType
            }),
          }
          if (options.type && options.type == "share") {
            setObj.imgUrls = [res.data];
            setObj.currentIndex = 0;
          }

          if(res.data.resourceType == 4){
            setObj.videoStyle = me.data.videoStyle;
            let videoobj = res.data;
            let quyuHeight = me.data.windowHAW.windowHeight - 90 + (res.data.description ? -230 : -170);
            if(videoobj.width < videoobj.height){
                setObj.videoStyle.height = quyuHeight;
            }else{
                setObj.videoStyle.marginTop = setObj.videoStyle.marginTop + (quyuHeight - setObj.videoStyle.height)/2;
            }
          }
          
          me.setData(setObj, ()=> {
            wx.hideLoading();
            me.shareAnimation();
            // me.setContentHeight()
            me.setData({
              mstyle: {
                marginTop: res.data.description ? -260 : -170,
              },
              isChanging: false,
              indexChanged: false
            })
          });
        
        } else {
          wx.hideLoading();
          console.log(res.errMsg);
        }
      },
      fail:function(e){
        wx.hideLoading();
      }
    });
  },
  aferOnLoad: function (options){
    let me = this;
    if (options.type && options.type == "share"){
      Swiper.resetData();
    }else{
      if (Swiper.data.imgUrls.length) {
        let imgUrls = Swiper.data.imgUrls;
        let currentIndex = 0;
        for (let i = 0; i < imgUrls.length;i++){
          if (imgUrls[i].id == Swiper.data.selectedID){
            currentIndex = i;
          }
        }
        this.setData({
          imgUrls: imgUrls,
          currentIndex: currentIndex,
        });
      }
    }
    wx.showLoading({
      title: 'loading...',
      mask: true
    });
    this.afterLoginFun(options);
  },
  photoTouchChange:function(e){
    let options = this.data.options;
    let curList = this.data.imgUrls;
    let curIdx = e.detail.current;
    if (stopFlag){
      stopFlag = false
    }
    this.setData({
      currentIndex: curIdx,
      allText: true,
      hasArrow: true,
      isChanging: true,
      indexChanged: true
    },()=>{
      wx.pageScrollTo({
        scrollTop: 0,
      })
    });
    Swiper.setData({ selectedID: curList[curIdx].id});
    options.id = curList[curIdx].id;
    options.resourceType = curList[curIdx].resourceType;
    this.afterLoginFun(options);
    if ((curIdx + 1) == curList.length){
      //加载下一页
      Swiper.nextPage((imgUrls)=>{
        this.setData({
          imgUrls: imgUrls,
        });
      });
    }
  },
  swiperTransition(e) {
    // if (!this.data.isChanging) {
    //   this.setData({
    //     isChanging: true,
    //   })
    // }
  },
  transitionFinished(e) {
    // if (!this.data.indexChanged) {
    //   this.setData({
    //     isChanging: false,
    //   })
    // }
  },
  onLoad: function(options) {
    let me = this;
    wx.getSystemInfo({
      success: function (res) {
        me.setData({
          windowHAW: {
            windowWidth: res.windowWidth,
            windowHeight: res.windowHeight,
          },
          screenWidth: res.screenWidth
        });
      }
    });
    if (options.photoId){
      //app传参
      options.id = options.photoId;
      options.type = "share";
    }
    if (options.scene) {
      let scene = decodeURIComponent(options.scene);
      getparamstr(scene, function (paramStr) {
        if (paramStr.search('&') != -1) {
          let sceneArray = paramStr.split("&");
          options.id = sceneArray[0];
          options.resourceType = sceneArray[1];
          options.type = sceneArray[2];
          if (sceneArray.length == 5){
            options.fromType = sceneArray[3];
            options.fromResourceId = sceneArray[4];
          }
        }
        me.aferOnLoad(options);
      })
    } else {
      me.aferOnLoad(options);
    }
    this.changePhotoList();

  },
  touchStart: function(e) {
    startPoint = e.touches[0]
  },
  imgOnload: function(e) {
    let windowHAW = this.data.windowHAW;
    let imgWidth = e.detail.width;
    let imgHeight = e.detail.height;
    let curImgWidth;
    let curImgHeight;
    let calcWH = () => {
      curImgWidth = windowHAW.windowWidth;
      curImgHeight = imgHeight / imgWidth * curImgWidth;
    }
    if (imgWidth > imgHeight) {
      //长图
      calcWH();
    } else {
      //竖图
      curImgHeight = windowHAW.windowHeight - this.data.navBarHeight;
      curImgWidth = imgWidth / imgHeight * curImgHeight;
      if (curImgWidth > windowHAW.windowWidth) {
        calcWH();
      }
    }
    let emptyH = (windowHAW.windowHeight - curImgHeight - this.data.navBarHeight) / 2;
    let curImgInfo = {
      width: curImgWidth,
      height: curImgHeight,
      emptyH: emptyH
    };
    imgUrlsCoverInfo[e.currentTarget.dataset.curindex] = curImgInfo;

  },
  touchMove: function(e) {
    if(this.data.fullImgFlag){
      return;
    }
    var endPoint = e.touches[e.touches.length - 1];
    if ((endPoint.clientY - startPoint.clientY) < 0 && this.data.hasArrow){
      this.setData({
        hasArrow: false
      })
    }

    let curImgInfo = imgUrlsCoverInfo[this.data.currentIndex];
    if ((endPoint.clientY - startPoint.clientY) < 0 && !stopFlag) {
      let coverH = curImgInfo ? - this.data.mstyle.marginTop - curImgInfo.emptyH : '';
      if (coverH) {
        this.setData({
          mstyle: {
            marginTop: coverH + this.data.mstyle.marginTop
          }
        })
        stopFlag = true;
      }
    }

  },
  touchEnd: function(e) {
    console.log('end');
  },
  stopTouchMove:function(){
    return false
  },
  scaleChange:function(e){
    let curScale = e.detail.curScale;
    let stopTouchMove = this.data.stopTouchMove;
    let value;
    if (curScale == 1){
      value = "";
    }else{
      value = "stopTouchMove"
    }
    if (stopTouchMove != value){
      this.setData({
        stopTouchMove: value
      })
    }

  },
  toHomeFeed:function(){
    wx.reLaunch({
      url: '/pages/contestList/contestList',
    });
  },

  closeMsg() {
    this.setData({
      tipMsg: ''
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {


  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    if (this.data.freshMark == undefined || !this.data.freshMark) {
      return;
    }

    let options = this.data.options;

    startPoint= {};
    stopFlag = false;
    this.afterLoginFun(options)

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {
    this.setData({
      freshMark: false
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {
    stopFlag = false;
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function(res) {
    let photoData = this.data.photoData;
    let title = photoData.title;
    if (!title) {
      title = photoData.uploaderName + "的作品";
    }
    let opt = this.data.options;
    let path = `/pages/detail/detail?id=${photoData.id}&resourceType=${photoData.resourceType}&type=share`;
    if (opt.fromType){
      path += `&fromType=${opt.fromType}`;
    }
    if (opt.fromResourceId){
      path += `&fromResourceId=${opt.fromResourceId}`;
    }
    return {
      title: title,
      path: path,
      imageUrl: photoData.url.baseUrl+'!wechat'
    }
  }
})
